package com.example.design.filter.enums;


import com.example.design.ServiceException;
import com.example.design.DataDictionary;

/**
 * 智能排班-排班班次 waring!!! 枚举顺序不要改，影响排序
 */
public enum ScheduleShiftEnum implements DataDictionary {

    PRE_SALE_DAY("pre_sale_day", "售前早班", "早班") {
        @Override
        public boolean isPreSale() {
            return true;
        }

        @Override
        public boolean isAfterSale() {
            return false;
        }
    },
    PRE_SALE_NIGHT("pre_sale_night", "售前晚班", "晚班") {
        @Override
        public boolean isPreSale() {
            return true;
        }

        @Override
        public boolean isAfterSale() {
            return false;
        }
    },

    AFTER_SALE("after_sale", "售后", "售后") {
        @Override
        public boolean isPreSale() {
            return false;
        }

        @Override
        public boolean isAfterSale() {
            return true;
        }
    },
    PRE_SALE_REST("pre_sale_rest", "售前休息", "休息") {
        @Override
        public boolean isPreSale() {
            return true;
        }

        @Override
        public boolean isAfterSale() {
            return false;
        }
    },
    AFTER_SALE_REST("after_sale_rest", "售后休息", "休息") {
        @Override
        public boolean isPreSale() {
            return false;
        }

        @Override
        public boolean isAfterSale() {
            return true;
        }
    },
    ;

    private final String dictCode;
    private final String dictName;
    private final String displayName;

    ScheduleShiftEnum(String dictCode, String dictName, String displayName) {
        this.dictCode = dictCode;
        this.dictName = dictName;
        this.displayName = displayName;
    }

    public abstract boolean isPreSale();

    public abstract boolean isAfterSale();

    public static ScheduleShiftEnum codeOf(String dictCode) {
        for (ScheduleShiftEnum shiftEnum : ScheduleShiftEnum.values()) {
            if (shiftEnum.getDictCode().equalsIgnoreCase(dictCode)) {
                return shiftEnum;
            }
        }
        throw new ServiceException("未知的排班班次");
    }

    @Override
    public String getDictCode() {
        return dictCode;
    }

    @Override
    public String getDictName() {
        return dictName;
    }

    @Override
    public String getDictItemDesc() {
        return dictCode;
    }

    @Override
    public int intValue() {
        return ordinal();
    }

    public String getDisplayName() {
        return displayName;
    }
}
